package double_pointer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-12-03
 * Time: 10:22
 */
public class RemoveDuplicates2 {
    private static void swap(int[] nums, int low, int fast) {
        int tmp = nums[low];
        nums[low] = nums[fast];
        nums[fast] = tmp;
    }
    public static int removeDuplicates(int[] nums) {
        int n = nums.length;
        if(n == 1 || n == 2) {
            return n;
        }
        int low = 2;
        int fast = 2;
        while (fast < n) {
            if (nums[low - 2] != nums[fast]) {
                nums[low] = nums[fast];
                low++;
            }
            fast++;
        }
        return low;
    }

    public static void main(String[] args) {
        removeDuplicates(new int[]{1,1,1,2,2,2,3,3});
    }
}
